/*
 * Copyright (c) 2024 Black Sesame Technologies
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "dal/guid.h"
#include <fastdds/rtps/common/Guid.h>

const uint8_t same_host_byte_num = 4;
const uint8_t same_proc_byte_num = 8;

BOOLEAN dal_guid_is_on_same_host(dal_guid_t* guid_1, dal_guid_t* guid_2)
{
    return memcmp(guid_1->guidprefix.value, guid_2->guidprefix.value, same_host_byte_num) == 0;
}

BOOLEAN dal_guid_is_on_same_process(dal_guid_t* guid_1, dal_guid_t* guid_2)
{
    return memcmp(guid_1->guidprefix.value, guid_2->guidprefix.value, same_proc_byte_num) == 0;
}

BOOLEAN dal_guidprefix_is_same(dal_guid_t* guid_1, dal_guid_t* guid_2)
{
    return memcmp(guid_1->guidprefix.value,
                  guid_2->guidprefix.value,
                  GUIDPREFIX_SIZE) == 0;
}
